<?php
$host = "localhost";
$port = 843;

$thread = 10;

echo "\n";

for($t = 0; $t < $thread; $t++)
{
	if (pcntl_fork() == 0)
	{
		$start = microtime(true);
		for($i = 0; $i< 10000; $i++)
		{
			sanbox_test($host, $port);
		}
		echo "thread:$t times $i time:" . (microtime(true) - $start) . "\n";
		exit;
	}

}

function sanbox_test($host, $port)
{
	$fp = fsockopen($host, $port, $errno, $errstr, 30);
	if (!$fp) {
		echo "$errstr ($errno)<br />\n";
	} else {
		fwrite($fp, "<policy-file-request/>");
		$str = fgets($fp, 128);
		fclose($fp);
		if (strlen($str) != 109)
			echo "error";
	}
}


